var BasePlanePart = require('./../BasePlanePart');
var BaseBullet = require('./../../Bullet/BaseBullet');
var EnumBody = require('./../../Enum/EnumBody');
var EnumIE = require('./../../Enum/EnumIE');
var UtilGameObject = require('./../../../../../FrameWork/Utils/UtilGameObject');
cc.Class(
{
    extends: BasePlanePart,
    properties:
    {
        prefabCarry:
        {
            default: null,
            type: cc.Prefab,
            displayName: '携带预设(本体死亡时会掉道具)'
        }
    },
    onCollisionEnter: function(other)
    {
        var body = this._super(other);
        if (null == body)
        {
            cc.error('发现不明物品请处理');
            return null;
        }

        if (EnumBody.BULLET == body.getEnumBody())
        {
            var baseBullet = other.node.getComponent(BaseBullet);
            /***被我机击中 */
            if (null != baseBullet && EnumIE.I == baseBullet.getEnumIE())
            {
                this.doCollision(other);
            }
        }
        return body;
    },

    // 处理碰撞逻辑
    doCollision(other)
    {
        this.dropProp(other);
        this._super(other);
    },

    /***执行掉落*/
    dropProp(other)
    {
        if (!!this.prefabCarry)
        {
            var propNode = UtilGameObject.createAddparentByPrefabs(this.prefabCarry, this.mainPlane.parent);
            var otherNode = other.node;
            propNode.x = otherNode.x;
            propNode.y = otherNode.y;
        }
    }
});
